package com.example.oauthserver.config;

import com.example.oauthserver.service.impl.CustomTokenEnhancerImpl;
import com.example.oauthserver.service.impl.MyTokenStoreService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;

@Configuration
public class TokenConfig {
    public static final String SIGNING_KEY = "Key123";
    @Bean
    public JwtAccessTokenConverter tokenConverter(){
        JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
        converter.setSigningKey(SIGNING_KEY);
        return converter;
    }

    @Bean
    public TokenStore tokenStore(){
        return new MyTokenStoreService(tokenConverter());
    }

    @Bean
    public TokenEnhancer tokenEnhancer(){
        return new CustomTokenEnhancerImpl();
    }
}
